
/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __POPUP_DIALOG_H__
#define __POPUP_DIALOG_H__

#include <iostream>

#include <components/ui_image_view.h>
#include <components/ui_view_group.h>
#include <components/ui_label.h>
#include <components/root_view.h>
#include <components/ui_label_button.h>

#include <common/task.h>

#include "securec.h"

namespace OHOS {
class PopupDialog : public Task {
public:
    static constexpr int DIALOG_TYPE_UNKNOW = -1;
    static constexpr int DIALOG_TYPE_SELECT = 0;
    static constexpr int DIALOG_TYPE_PROGRESS = 1;
    static constexpr int DIALOG_TYPE_FINISH = 2;

    PopupDialog();
    ~PopupDialog();
    void Create(RootView *rootView, int x, int y, int w, int h);
    int Display(const char *msg, int dialogType, int timeout);
    int GetResult();
    void Dismiss();
    bool GetDisplay();

    void Callback() override;

protected:
    void ShowDialogFinish(const char *msg);
    void ShowDialogProgress(const char *msg);
    void ShowDialogSelect(const char *msg);
private:
    RootView *rootView_ { nullptr };
    UIViewGroup *backgroup_ { nullptr };
    UIImageView *background_ { nullptr };
    UIImageView *backicon_ { nullptr };
    UILabelButton *okButton_ { nullptr };
    UILabelButton *cancelButton_ { nullptr };
    UILabel *msgText_ { nullptr };

    bool display_ = false;
    int timeout_ = 0;
    int dialogType_ = DIALOG_TYPE_UNKNOW;
    const char *pathHead_ { nullptr };
    std::string message_;

    static constexpr int ICON_START_X = 212;
    static constexpr int ICON_START_Y = 52;
    static constexpr int ICON_START_W = 248;
    static constexpr int ICON_START_H = 184;

    static constexpr int RECV_SELECT_TEXT_X = 0;
    static constexpr int RECV_SELECT_TEXT_Y = 193;
    static constexpr int RECV_SELECT_TEXT_W = 0;
    static constexpr int RECV_SELECT_TEXT_H = 64;

    static constexpr int RECV_PROGRESS_TEXT_X = 0;
    static constexpr int RECV_PROGRESS_TEXT_Y = 241;
    static constexpr int RECV_PROGRESS_TEXT_W = 0;
    static constexpr int RECV_PROGRESS_TEXT_H = 60;

    static constexpr int RECV_OK_TEXT_X = 0;
    static constexpr int RECV_OK_TEXT_Y = 193;
    static constexpr int RECV_OK_TEXT_W = 0;
    static constexpr int RECV_OK_TEXT_H = 64;

    static constexpr int LEFT_BUTTON_X = 201;
    static constexpr int LEFT_BUTTON_Y = 264;
    static constexpr int LEFT_BUTTON_W = 112;
    static constexpr int LEFT_BUTTON_H = 60;

    static constexpr int RIGHT_BUTTON_X = 369;
    static constexpr int RIGHT_BUTTON_Y = 264;
    static constexpr int RIGHT_BUTTON_W = 112;
    static constexpr int RIGHT_BUTTON_H = 60;

    static constexpr int MIDDLE_BUTTON_X = 265;
    static constexpr int MIDDLE_BUTTON_Y = 264;
    static constexpr int MIDDLE_BUTTON_W = 152;
    static constexpr int MIDDLE_BUTTON_H = 60;

    static constexpr int BUTTON_RADIUS = 6;

    static constexpr int TASK_TIME = 1000;

    static constexpr int FONT_SIZE = 24;

    const char *FONTNAME = "SourceHanSansSC-Regular.otf";
    const char *POPWIN_BACK_GROUND = "Hoods/res/image/hoods/ic_popwindow.png";
    const char *RECV_SELECT_ICON = "Hoods/res/image/hoods/ic_recv.png";
    const char *RECV_PROGRESS_ICON = "Hoods/res/image/hoods/ic_recv_progress.png";
    const char *RECV_OK_ICON = "Hoods/res/image/hoods/ic_recv_ok.png";
};
}
#endif  /* __POPUP_DIALOG_H__ */
